import {_ as e} from "./ContentWrap.vue_vue_type_script_setup_true_lang.6ff9ed7b1729265196717.js";
import {u as a, a as t, _ as l, b as r} from "./useCrudSchemas.2c3b314d1729265196717.js";
import {_ as s} from "./Dialog.vue_vue_type_style_index_0_lang.071fc2701729265196717.js";
import {c as o} from "./index.eec34c841729265196717.js";
import {
    d as n,
    r as i,
    g as u,
    w as c,
    G as d,
    o as m,
    c as p,
    B as v,
    k as f,
    a as g,
    j as _,
    i as h,
    l as b,
    p as y,
    H as w,
    E as x,
    I as j,
    h as k,
    s as R
} from "./index.115af62d1729265196717.js";
import {E as C} from "./el-button.c1876bd01729265196717.js";
import {u as F, F as S} from "./useForm.9355f9ab1729265196717.js";
import {E} from "./el-divider.111259cd1729265196717.js";
import "./tree.67a6f3e21729265196717.js";
import "./mitt.f0e547641729265196717.js";
import "./el-form-item.eb8d765c1729265196717.js";
import "./_plugin-vue_export-helper.1b428a4d1729265196717.js";

const L = e => o.get({url: "/backend/v1/cards", params: e}), O = e => o.delete({url: "/backend/v1/card/" + e}),
    A = e => o.post({url: "/backend/v1/card", data: e}), D = e => o.put({url: "/backend/v1/card", data: e}),
    P = {style: {"text-align": "center"}}, T = n({
        __name: "NewCard",
        props: {currentRow: {type: Object, default: () => null}, actionType: {type: String, default: () => null}},
        emits: ["success"],
        setup(e, {expose: a, emit: t}) {
            const l = e;
            i(!1);
            const r = i(), s = i(), o = i(!1), n = i(), j = async () => {
                L.getFormData().then((async e => {
                    if (o.value = !0, n.value + "" || (e.channel_id = n.value), "" === e.start_at && x.info("请选择合作开始日期!"), e.channel_id + "" == "" && x.info("请选择渠道商!"), r.value = A, s.value = D, "" === l.actionType) if (r.value) {
                        await r.value(e).catch((e => {
                            x.error(e.msg ? e.msg : "保存失败!")
                        })).finally((() => {
                            o.value = !1
                        })) && (x.success("保存成功!"), t("success"))
                    } else x.info("请重新进入页面!"); else if (s.value) {
                        await s.value(e).catch((e => {
                            x.error(e.msg ? e.msg : "编辑失败!")
                        })).finally((() => {
                            o.value = !1
                        })) && (x.success("编辑成功!"), t("success"))
                    } else x.info("请重新进入页面!")
                }))
            }, k = u([{field: "card_no", label: "卡号", component: "Input", colProps: {span: 22}}]), {
                register: R,
                methods: L,
                elFormRef: O
            } = F({schema: k});
            return c((() => l.currentRow), (e => {
                if (!e) return;
                const {setValues: a} = L;
                a(e)
            }), {deep: !0, immediate: !0}), a({elFormRef: O, getFormData: L.getFormData}), (e, a) => {
                const t = d("loading");
                return m(), p(w, null, [v(f(g(S), {
                    style: {"padding-bottom": "60px"},
                    onRegister: g(R)
                }, null, 8, ["onRegister"]), [[t, o.value]]), _("div", {
                    style: {
                        position: "absolute",
                        right: "0%",
                        bottom: "0%",
                        width: "100%",
                        "z-index": "100",
                        opacity: "1"
                    },
                    class: y(["bg-[var(--el-color-white)] dark:bg-[var(--el-bg-color)] dark:border-[var(--el-border-color)]"])
                }, [f(g(E), {style: {margin: "0 0 15px"}}), _("div", P, [f(g(C), {
                    type: "primary",
                    onClick: j
                }, {default: h((() => [b("保存")])), _: 1})])], 2)], 64)
            }
        }
    }), V = n({
        __name: "CardNumberList", setup(o) {
            const {register: n, tableObject: c, methods: d} = a({getListApi: L, delListApi: O, response: {list: "data"}}),
                v = i(!1), _ = i(!1), y = i(""), x = i(""), {getList: F, setSearchParams: S, setExportFile: E} = d, A = i(),
                D = i(!1);
            F();
            const P = () => {
                y.value = "新增", c.currentRow = null, _.value = !0, x.value = ""
            }, V = () => {
                _.value = !1, F()
            }, I = () => {
                d.setAppendParams({channel_id: "", name: ""}), c.currentPage = 1
            }, N = u([{field: "index", label: "序号", type: "index"}, {
                field: "card_no",
                label: "卡号",
                search: {show: !0}
            }, {field: "created_at", label: "创建时间", search: {show: !1}}, {
                field: "operate",
                isCustom: !1,
                width: "200px",
                label: "操作"
            }]), {allSchemas: U} = t(N);
            return (a, t) => (m(), p(w, null, [f(g(e), null, {
                default: h((() => [f(g(l), {
                    schema: g(U).searchSchema,
                    showExportFile: D.value,
                    onSearch: g(S),
                    onReset: I,
                    onCreated: P,
                    onExportFile: g(E)
                }, null, 8, ["schema", "showExportFile", "onSearch", "onExportFile"])])), _: 1
            }), f(g(e), null, {
                default: h((() => [f(g(r), {
                    tableObject: g(c),
                    "onUpdate:tableObject": t[0] || (t[0] = e => j(c) ? c.value = e : null),
                    columns: g(U).tableColumns,
                    data: g(c).tableList,
                    selection: !1,
                    align: "center",
                    reserveIndex: !0,
                    border: "",
                    headerAlign: "center",
                    pagination: {total: g(c).total},
                    onRegister: g(n)
                }, {
                    operate: h((({row: e}) => [f(g(C), {
                        type: "primary", plain: "", onClick: a => ((e, a) => {
                            y.value = "edit" === a ? "编辑" : "新增", x.value = a, c.currentRow = e, _.value = !0
                        })(e, "edit")
                    }, {default: h((() => [b("编辑")])), _: 2}, 1032, ["onClick"]), f(g(C), {
                        type: "danger",
                        onClick: a => (async (e, a) => {
                            var t;
                            c.currentRow = e;
                            const {delList: l, getSelections: r} = d;
                            v.value = !0, await l(null == (t = c.currentRow) ? void 0 : t.id).finally((() => {
                                v.value = !1
                            }))
                        })(e)
                    }, {default: h((() => [b("删除")])), _: 2}, 1032, ["onClick"])])), _: 1
                }, 8, ["tableObject", "columns", "data", "pagination", "onRegister"])])), _: 1
            }), f(g(s), {
                modelValue: _.value,
                "onUpdate:modelValue": t[1] || (t[1] = e => _.value = e),
                title: y.value
            }, {
                default: h((() => ["detail" !== x.value ? (m(), k(T, {
                    key: 0,
                    ref_key: "writeRef",
                    ref: A,
                    "form-schema": g(U).formSchema,
                    "current-row": g(c).currentRow,
                    actionType: x.value,
                    onSuccess: V
                }, null, 8, ["form-schema", "current-row", "actionType"])) : R("", !0)])), _: 1
            }, 8, ["modelValue", "title"])], 64))
        }
    });
export {V as default};
